/**
 * Copyright (c) 2017,安徽皖通科技股份有限公司 All rights reserved.
 * @data:2017年9月25日
 * @author:MaShibo
 */
package com.wttech.dzzf.process.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wtkj.vo.dzzf.base.yhgl.SXCity;
import com.wtkj.vo.dzzf.base.yhgl.SXCounty;
import com.wtkj.vo.dzzf.share.staticvalue.SXDivisionValue.CityId;
import com.wtkj.vo.dzzf.share.staticvalue.SXDivisionValue.CountyId;
import com.wttech.dzzf.process.dao.ProcessSXDivisionInfoDao;

/**
 * 陕西省行政区划信息处理
 * 
 * @date 2017年9月25日
 * @author MaShibo
 */
@Service
public class SaveSXDivsionInfoService {
    
    
    private ProcessSXDivisionInfoDao processSXDivisionInfoDao;
    
    @Autowired
    public SaveSXDivsionInfoService(ProcessSXDivisionInfoDao processSXDivisionInfoDao) {
        this.processSXDivisionInfoDao = processSXDivisionInfoDao;
    }
    
    public void process() {
        try {
            
            processSXDivisionInfoDao.clearup();
            
            // 地市信息
            for (CityId cityId : CityId.values()) {
                SXCity city = new SXCity();
                city.setId(cityId.getValue());
                city.setName(cityId.getName());
                processSXDivisionInfoDao.createValueObject(city);
            }
            
            // 区县信息
            for (CountyId countyId : CountyId.values()) {
                SXCounty county = new SXCounty();
                String no = countyId.getValue();
                county.setId(no.substring(2));
                county.setCityId(no.substring(0, 2));
                county.setName(countyId.getName());
                processSXDivisionInfoDao.createValueObject(county);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
